/*
*
==============================================================================
*  Name        : 
*  Part of     : Omen Game Engine
*  Description : 
*  Version     : 1.0
*
*  Copyright (c) 2013 Lauri Kortevaara.
* 
==============================================================================
*/

#pragma once

/// Omen Headers
#include "OmenConfig.h"
#include "OmenMath.h"
#include "OmenQuaternion.h"

/// STL Headers
#include <vector>

namespace Omen
{

    class Transform
    {
    public:
        OMEN_API Transform();
        OMEN_API Transform( const Transform& other );
        OMEN_API virtual ~Transform();

        OMEN_API virtual void setPosition( const Omen::Vector3d& v );
        OMEN_API virtual void setRotation( const Omen::Vector3d& r );

        OMEN_API virtual void translate( const Omen::Vector3d& v );  /// <summary>Translate the transform by given vector3d</summary>
        OMEN_API virtual void rotate( const Omen::Vector3d& r );     /// <summary>Rotate the transform by Euler angles defined by Vector3d(x,y,z). First around z-axis , then x-, and last the y-axis</summary>
        OMEN_API virtual void rotateAround( const Omen::Vector3d& point, const Omen::Vector3d& axis, const Omen::Float& angle ); /// <summary>Rotate transform about axis passing through point in world coordinates by angle in degrees</summary>
        
        OMEN_API virtual void lookAt( const Omen::Vector3d& target );      /// <summary>Rotates the transform so that it's forward is pointing to the target coordinate</summary>

        OMEN_API virtual Omen::Matrix4x4& transformation();

    protected:
    
    private:
        //#pragma warning(disable:4251) // Disable warning about private member variable needs to have dll-interface to be used by clients of class 'this'
        Omen::Matrix4x4         m_transformation;       /// The transformation matrix having the rotation and translation
        
        Omen::Quaternion        m_rotation;             /// Quaternion representing the rotation
        Omen::Quaternion        m_localRotation;        /// Quaternion representing the rotation relative to parent transform
        
        Omen::Vector3d          m_position;             /// Position in world space
        Omen::Vector3d          m_localPosition;        /// Position relative to parent transform
        
        Omen::Vector3d          m_eulerAngles;          /// Rotation in Euler angles
        Omen::Vector3d          m_localEulerAngles;     /// Rotation relative to parent transform

        Omen::Vector3d          m_right;                /// Orthogonal base unit vector representing right direction in left-hand-coordinate system
        Omen::Vector3d          m_up;                   /// Orthogonal base unit vector representing up direction in left-hand-coordinate system
        Omen::Vector3d          m_forward;              /// Orthogonal base unit vector representing forward direction in left-hand-coordinate system

        Omen::Vector3d          m_localScale;           /// Scale-vector relative to parent transform

        std::unique_ptr<Omen::Transform> m_pParent;     /// Parent Transform, if null-ptr this is the root-transform
        std::vector< std::unique_ptr<Omen::Transform> > m_children; /// Child transforms
    };
}

/// EOF